﻿
@{
    ViewBag.Title = "添加用户";
    ViewBag.MemCss = "active";
}
<ul class="breadcrumb">
    <li>用户管理<span class="divider">/</span></li>
    <li class="active">@ViewBag.Title</li>
</ul>
<div class="container-fluid">
    <div class="row-fluid">

        <div class="row-fluid">

            <div class="btn-toolbar">
                <button class="btn btn-primary" onclick="save()"><i class="fa fa-save"></i> Save</button>
                <div class="btn-group">
                </div>
            </div>
            <div>
                <label>登陆名</label>
                <input type="text" id="login" name="login" style="width:200px;" maxlength="15">
                <label>密码</label>
                <input type="password" id="pwd" name="pwd" style="width:200px;" maxlength="20">
                <label>确认密码</label>
                <input type="password" id="qrpwd" name="qrpwd" style="width:200px;" maxlength="20">
                <label>级别</label>
                <select name="level" id="level">
                    <option value="1" selected="selected">管理员</option>
                </select>
                <label>名称</label>
                <input type="text" id="name" name="name" style="width:200px;" maxlength="15">
            </div>
        </div>



        @Html.Partial("_footer")

    </div>
</div>


<script>

    //保存
    function save()
    {
        var name = $("#name").val();
        var login = $("#login").val();
        var pwd = $("#pwd").val();
        var qrpwd = $("#qrpwd").val();
        var level = $("#level").val();
        if (name == "")
        {
            AlertDialog("名称不能为空！");
            return;
        }
        if (pwd.length < 6) {
            AlertDialog("密码不能少于6位！");
            return;
        }
        if (pwd != qrpwd) {
            AlertDialog("两次输入的密码不正确！");
            return;
        }

        var data = [{ 'name': 'name', 'value': name },
            { 'name': 'login', 'value': login },
            { 'name': 'pwd', 'value': pwd },
            { 'name': 'level', 'value': level }
        ];
        AjaxPost('/Admin/Member/MemAdd', data, function (mess) {
            AlertDialog(mess.msg, function () {
                if(mess.code==200)
                {
                    location.href = "/Admin/Member/List";
                }
            });
        });
    }
</script>

